class ScorePanel {
    score : number = 0;
    level : number = 1;
    scoreEle : HTMLElement;
    levelEle : HTMLElement;
    constructor(public maxlevel : number = 10,public upScore: number = 10) {
        this.scoreEle = document.getElementById('score')!;
        this.levelEle = document.getElementById('level')!;
    }
    addScore() {
        this.scoreEle.innerHTML = ++this.score + '';
        if(this.score % this.upScore == 0){
            this.levelUp();
        }
    }
    levelUp() {
        if(this.level < this.maxlevel ){
            this.levelEle.innerHTML = ++this.level + '';
        }
    }
}
export default ScorePanel;
// 测试代码
// let snake = new ScorePanel(10,2);
// setInterval(() => {
//     snake.addScore();  
// },1000)
